{{if $allContent|@count > 0}}
<form method="POST" name="sortForm">
<table>
	<thead>
		<tr>
			<th width="3%"><input class="check-all" type="checkbox" /></th>
			<th width="3%">#</th>
			<th width="10%">Category</th>
			<th width="10%">Created</th>
			<th class="center" width="4%">Sort 
				{{if $fullPermisison}} 
				<a href="javascript:sortContent();">
					<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/save_16.png" alt="Save sorting">
				</a> 
				{{/if}}
<!--				<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/save_16.png" alt="Save sorting">-->
			</th>
			<th width="50%">Title</th>
			<th width="5%">Hit</th>
			<th width="5%">Pub</th>
			<th width="5%">Edit</th>
			<th width="5%">GID/ID</th>
		</tr>

	</thead>

	<tbody>

		{{foreach from=$allContent item=item name=content}}
		<tr>
			<td>
				{{if 1 == $item.content_deleteable}}
					<input type="checkbox" value="{{$item.content_gid}}" name="allContent" />
				{{else}}
					<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/unselect.png" alt="Do not delete, enable, disable" />
				{{/if}}
			</td>
			<td>{{$smarty.foreach.content.iteration}}</td>
			<td>{{$item.cname}}</td>
			<td>{{$item.created_date}}</td>
			<td class="center">
				{{if $fullPermisison}} 
					<input class="sorting" name="data[{{$item.content_gid}}]" value="{{$item.sorting}}" size="3" style="text-align: center;" />
				{{else}}
					{{$item.sorting}} 
				{{/if}}
			</td>

			<td colspan="5" style="padding: 0px;"><!-- All languages -->
			<table style="border-collapse: separate">
				<tbody id="table{{$item.content_id}}">
					<tr>
						<td width="68">--</td>
						<td width="7%">{{$item.hit}}</td>
						<td width="7%">
							{{if $item.genabled == '1' }} 
								{{if $fullPermisison && 1 == $item.content_deleteable}} 
								<a href="javascript:disableAContent({{$item.content_gid}});">
									<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/visible16x16.png">
								</a>
								{{else}} 
								<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/visible16x16.png">
								{{/if}} 
							{{else}} 
								{{if $fullPermisison && 1 == $item.content_deleteable}} 
								<a href="javascript:enableAContent({{$item.content_gid}});">
									<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/invisible16x16.png">
								</a>
								{{else}} 
								<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/invisible16x16.png">
								{{/if}} 
							{{/if}}
						</td>
						<td width="10%">
							{{if $fullPermisison}} 
							{{if false != $pid}}
								<a href="javascript:editContent({{$pid}},{{$item.content_gid}});" title="Edit Content">
									<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/pencil.png" alt="Edit Content" />
								</a> 
							{{else}}
								<a href="javascript:editContent(null,{{$item.content_gid}});" title="Edit Content">
									<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/pencil.png" alt="Edit Content" />
								</a> 
							{{/if}}
							
							{{else}} -- {{/if}}
						</td>
						<td width=8%">{{$item.content_gid}}</td>
					</tr>

					{{foreach from=$item.langs item=item2}}
					<tr>
						<td>
							<img style="vertical-align:middle;" src="{{$BASE_URL}}{{$item2.lang_image}}"> {{$item2.title}}
						</td>
						<td>{{$item2.hit}}</td>
						<td>
							{{assign var='langId' value=$item2.lang_id}} 
							
							{{if $item.genabled == '1'}} 
							
								<!-- FULL PERMISSION --> 
								{{p name=edit_content module=content expandId=$langId}} 
									{{if $item2.enabled == '1'}} 
										{{if 1 == $item.content_deleteable}} 
											<a href="javascript:disableAContent({{$item.content_gid}},{{$item2.lang_id}});">
												<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/visible16x16.png">
											</a>
										{{else}} 
											<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/visible16x16.png">
										{{/if}} 
									{{else}} 
										{{if 1 == $item.content_deleteable}} 
											<a href="javascript:enableAContent({{$item.content_gid}},{{$item2.lang_id}});">
												<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/invisible16x16.png">
											</a>
										{{else}} 
											<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/invisible16x16.png">
										{{/if}} 
									{{/if}} 
								{{/p}} 
								
								<!-- DON'T HAVE PERMISSION --> 
								
								{{np name=edit_content module=content expandId=$langId}} 
									{{if $item2.enabled == '1'}} 
										<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/visible16x16.png">
									{{else}} 
										<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/invisible16x16.png">
									{{/if}} 
								{{/np}} 
							
							{{else}} 
								<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/invisible16x16.png">
							{{/if}}
						</td>
						<td>
							{{p name=edit_content module=content expandId=$langId}} 
								{{if false != $pid}}
									<a href="javascript:editContent({{$pid}},{{$item.content_gid}},{{$item2.lang_id}});" title="Edit Content">
										<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/pencil.png" alt="Edit Content" />
									</a> 
								{{else}}
									<a href="javascript:editContent(null,{{$item.content_gid}},{{$item2.lang_id}});" title="Edit Content">
										<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/pencil.png" alt="Edit Content" />
									</a>
								{{/if}}
							{{/p}} 
							
							{{np name=edit_content module=content expandId=$langId}}
							 -- 
							 {{/np}}
						</td>
						<td>{{$item2.content_id}}</td>
					</tr>
					{{/foreach}}

				</tbody>
			</table>
			</td>
		</tr>
		{{/foreach}}
	</tbody>
</table>
</form>

<br/>
<!-- CHOOSE ACTION -->
                        {{p name=edit_content module=content}}
                        <div class="bulk-actions align-left" style="float: left;padding-top: 14px;">
                            <select id="action">
                                <option value=";">Choose an action...</option>
                                {{p name=delete_content module=content}}
                                <option value="deleteContent();">Delete</option>
                                {{/p}}
                                <option value="enableContent();">Enable</option>
                                <option value="disableContent();">Disable</option>
                            </select>
                            <a class="button" href="javascript:applySelected();">Apply to selected</a>
                        </div>
                        {{/p}}
<div class="clear"></div>
{{else}}

<!-- MESSAGE HERE -->
<div class="notification information png_bg">
	<a href="#" class="close">
		<img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross_grey_small.png"
		title="Close this notification" alt="close" />
	</a>
	<div>No product content existing.</div>
</div>


{{/if}} 

<p>
	<br />
	<input class="button" type="button" value="New Content" onclick="javascript:newContent({{$pid}});" />
</p>


<script type="text/javascript">
function newContent(pid)
{
	url = "{{$APP_BASE_URL}}content/extend/new-content";
	if (null != pid) {
		url = url + '/pid/' + pid;
	}
	
	window.open( url, "myWindow", "status = 1, width = 1000, scrollbars = 1");
}

function editContent(pid,gid,lid)
{
	var url = "{{$APP_BASE_URL}}content/extend/edit-content";
	if (null != pid) {
		url = url + "/pid/" + pid;
	}
	if (null != gid) {
		url = url + "/gid/" + gid;
	}
	if (null != lid) {
		url = url + "/lid/" + lid;
	}

	window.open(url, "myWindow", "status = 1, width = 1000, scrollbars = 1");
}
</script>
